import * as React from 'react';
import { Form, Popconfirm, Button } from 'antd';
import validation from "../../utils/validation";
import ITable from "../../components/ITable"
import IAddress from "../../components/IAddress"
import ITxAddress from "../../components/ITxAddress"






const Recharge: React.FC = (props) => {

    const url: string = "admin/wallet/GSW/withdraws"
    const rowKey: string = "id"
    const filterData = {
        q: "",
        status: "INIT"
    }


    const filter = [
        {
            type: "text",
            name: "q",
            label: "关键字",
            validation: validation.string,
        },
        {
            type: "select",
            name: "status",
            label: "",
            items: [{
                key: "INIT",
                value: "待审核"
            },
            {
                key: "SUCCESS",
                value: "审核通过"
            },
            {
                key: "DONE",
                value: "已处理"
            },
            {
                key: "FAIL",
                value: "已拒绝"
            }]
        },

    ];

    const ITButton: React.FC = () => {
        return (<>
        </>)
    }
    const columns = [
        {
            title: "流水号",
            dataIndex: "id",
        },
        {
            title: "申请时间",
            dataIndex: "createTime",
            width: 240
        },
        {
            title: "提现账号",
            dataIndex: "userMobile",

        },
        {
            title: "详情",
            dataIndex: "outQuantity",
            width: 240,
            render: (value: any, record: any) => {
                return <>
                    <p>提现金额:{record.outQuantity}</p>
                    <p>手续费:{record.fee}</p>
                </>
            }
        },
        {
            title: "详情",
            dataIndex: "address",
            width: 360,
            render: (value: string, record: any) => {
                return <>
                    <p>提现到：</p>
                    <p><IAddress username={value.replace("0x", '')} /></p>
                    {!!record.tip && <>
                        <p>备注：{record.tip}</p>
                    </>}
                    {!!record.txId && <>
                        <p>转账HASH：</p>
                        <p><ITxAddress tx={record.txId} /></p>
                    </>}
                </>
            }
        },
        {
            title: "状态",
            dataIndex: "status",
            fixed: "right",
            render: (value: any, record: any) => {
                const status: any = {
                    FAIL: "已拒绝",
                    DONE: "已处理",
                    INIT: "待审核",
                    SUCCESS: "审核通过"
                };
                return <>{status[value]}</>;
            }
        },
        {
            title: "操作",
            fixed: "right",
            width: 120,
            render: (value: any, record: any) => {
                return <>
                    {
                        record.status == "INIT" && <>
                            <p>
                                <Popconfirm
                                    placement="leftTop"
                                    title="是否同意该次提现"
                                    onConfirm={() => {
                                        debugger
                                    }}
                                    okText="同意"
                                    cancelText="取消"
                                >
                                    <Button type="link">同意</Button>
                                </Popconfirm>
                            </p>
                            <p>
                                <Popconfirm
                                    placement="leftTop"
                                    title="是否拒绝该次提现"
                                    onConfirm={() => {
                                        debugger
                                    }}
                                    okText="拒绝"
                                    cancelText="取消"
                                >
                                    <Button type="link">拒绝</Button>
                                </Popconfirm>
                            </p>
                        </>
                    }
                    {
                        record.status == "SUCCESS" && <>
                            <p><a>处理</a></p>
                        </>
                    }
                    {
                        record.status != "INIT" && <>
                            <p><a>更改状态</a></p>
                        </>
                    }
                </>
            }
        }
    ]

    return (<div>
        <ITable
            {...props}
            columns={columns}
            filterData={filterData}
            filter={filter}
            url={url}
            rowKey={rowKey}
            ITButton={ITButton}
        />
    </div>)
}
export default Form.create({ name: 'Recharge' })(Recharge);